package com.ctgu.chatapp.view.adapter

import androidx.recyclerview.widget.DiffUtil
import com.ctgu.chatapp.showPojo.Contact

class DiffCallBackForFriend(var oldList: List<Contact>, var newList: List<Contact>) :
    DiffUtil.Callback() {
    override fun getOldListSize() = oldList.size

    override fun getNewListSize() = newList.size

    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) =
        oldList[oldItemPosition].chatID == newList[newItemPosition].chatID

    override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        val old = oldList[oldItemPosition]
        val new = newList[newItemPosition]
        return (old.nickName == new.nickName) && (old.motto == new.motto) && (old.profile == new.profile)
    }
}